package com.imelite.qyh.base;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

public class ApplicationContextHelper implements ApplicationContextAware {
    private static ApplicationContext appCtx;

    public static ApplicationContext getApplicationContext(){
        return appCtx;
    }

    public static Object getBean(String beanName) {
        ApplicationContext applicationContext = getApplicationContext();
        return applicationContext.getBean(beanName);
    }

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        appCtx = applicationContext;
    }
}
